﻿// CQueryUserDlg.cpp: 实现文件
//

#include "pch.h"
#include "HotelManagementMFC.h"
#include "afxdialogex.h"
#include "CQueryUserDlg.h"


// CQueryUserDlg 对话框

IMPLEMENT_DYNAMIC(CQueryUserDlg, CDialog)

CQueryUserDlg::CQueryUserDlg(CWnd* pParent /*=nullptr*/)
	: CDialog(IDD_DLG_USER_QUERY, pParent)
{

}

CQueryUserDlg::~CQueryUserDlg()
{
}

void CQueryUserDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST_USER, m_listUser);
	DDX_Control(pDX, IDC_USERNAME, m_sPaperName);
}


BEGIN_MESSAGE_MAP(CQueryUserDlg, CDialog)
	ON_BN_CLICKED(ID_SEARCH, &CQueryUserDlg::OnBnClickedSearch)
END_MESSAGE_MAP()


// CQueryUserDlg 消息处理程序


BOOL CQueryUserDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  在此添加额外的初始化
	m_listUser.InsertColumn(0, L"用户编号", LVCFMT_CENTER, 80);
	m_listUser.InsertColumn(1, L"用户名", LVCFMT_CENTER, 80);
	m_listUser.InsertColumn(2, L"用户密码", LVCFMT_CENTER, 80);
	m_listUser.InsertColumn(3, L"用户类型", LVCFMT_CENTER, 80);

	m_listUser.ModifyStyle(0, LVS_REPORT | LVS_SHOWSELALWAYS);
	m_listUser.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);

	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}


void CQueryUserDlg::OnBnClickedSearch()
{
	// TODO: 在此添加控件通知处理程序代码
	UpdateData(1);
	CString search_Name;
	m_sPaperName.GetWindowTextW(search_Name);
	if (search_Name == "")
	{
		MessageBoxW(L"用户名不能为空，请重新输入！");
		return;
	}
	// TODO: Select User Info
}
